﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Coldairarrow.Business.Home;
using Coldairarrow.Entity.Home;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;

namespace Coldairarrow.Api.Controllers.backstage
{
    [Route("/Home/[controller]/[action]")]
    public class BKS_NewProductsController : BaseApiController
    {
        #region DI

        public BKS_NewProductsController(IBTB_NewProductsBusiness bTB_NewProductsBus)
        {
            _bTB_NewProductsBus = bTB_NewProductsBus;
        }

        IBTB_NewProductsBusiness _bTB_NewProductsBus { get; }

        #endregion

        #region 获取
        /// <summary>
        /// 广告列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [NoCheckJWT]
        [HttpPost]
        public async Task<PageResult<BTB_NewProducts>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _bTB_NewProductsBus.GetDataListAsync(input);
        }
        /// <summary>
        /// 获取
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [NoCheckJWT]
        [HttpPost]
        public async Task<List<BTB_NewProducts>> GetTheData(IdInputDTO input)
        {
            return await _bTB_NewProductsBus.GetTheDataAsync(input.id);
        }
        /// <summary>
        /// 添加或修改广告
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task SaveData(BTB_NewProducts data)
        {
            if (data.id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _bTB_NewProductsBus.AddDataAsync(data);
            }
            else
            {
                await _bTB_NewProductsBus.UpdateDataAsync(data);
            }
        }
        [HttpPost]
        public async Task DeleteDataAsync(List<string> ids)
        {
            await _bTB_NewProductsBus.DeleteDataAsync(ids);
        }
        #endregion

    }
}
